package cn.edu.zut.salarymanagesystem.utils;

import android.util.Log;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class MD5Helper {
    public static String calc(byte[] bytes) {
        try {
            MessageDigest md = MessageDigest.getInstance("MD5");
            byte[] digest = md.digest(bytes);

            StringBuilder md5Digest = new StringBuilder();
            for (byte b : digest) {
                md5Digest.append(String.format("%02x", b));
            }
            return md5Digest.toString();
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
            Log.e("d8g", e.getMessage());
            return "Exception MD5:" + e.getMessage();
        }
    }
}
